<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .bg {
            width: 500px;
            height: 100px;
            line-height: 100px;
            text-align: center;
            background-color: pink;
        }

        .active {
            color: red;
        }

        .under {
            text-decoration: underline;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- :class -> v-bind:class 简写 -->
        <!-- 多个类可用一下写法，也可单独声明类，且不会被覆盖 -->

        <!-- <h2 class="bg" :class="{类名:布尔值, 类名:布尔值}">{{message}}</h2> -->
        <!-- <h2 class="bg" :class="{active: isActive, under:isUnder}">{{message}}</h2> -->
        <h2 class="bg" :class="getClasses()">{{message}}</h2>
        <button @click='btnClick'>点击</button>
    </div>
    <script src='../js/vue.js'></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                message: '重庆对外经贸学院-男孩子的天堂!',
                isActive: true,
                isUnder: true
            },
            methods: {
                btnClick() {
                    this.isActive = !this.isActive;
                    this.isUnder = !this.isUnder;
                },
                getClasses() {
                    return {active: this.isActive, under:this.isUnder};
                }
            }
        })
    </script>
</body>

</html>